#  display:
#    - time,
#    -  t, h
#    -  ip
#    -  cpu temp

import time
from datetime import datetime

from monitor_info.RPi_I2C_driver import *
from monitor_info.display_lcd1602 import LCD1602
from monitor_info.monitor_dht11 import DHT11

from monitor_info.sys_info import get_ip,get_temp

lcd=LCD1602()
lcd.display_begin_info()
sleep(2) 
lcd.lcd.lcd_clear()

network_interface_name=None
str_ip=get_ip(network_interface_name)
lcd.lcd.lcd_display_string_pos(str_ip[-3:], 1,13)

dht11=DHT11()
while True:
    # time
    currentDateAndTime = datetime.now()
    currentTime =currentDateAndTime.strftime("%H:%M:%S")
    lcd.lcd.lcd_display_string_pos(currentTime, 1,3)
    # t,h
    dht11.get_th()
    th_string="T "+f"{dht11.t:.0f}"+" H "+f"{dht11.h:.0f}"+"%"
    lcd.lcd.lcd_display_string_pos(th_string, 2,2)
    # cpu temp
    str_cpu_t= f"{get_temp():.0f}"
    lcd.lcd.lcd_display_string_pos(str_cpu_t, 2,14)
    sleep(1)      